package com.hwadee.controller;

import com.hwadee.pojo.Keypopulation;
import com.hwadee.service.KeypopulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/hd/keypopulation")
@CrossOrigin
public class KeypopulationController {

    @Autowired
    private KeypopulationService keypopulationService;

    @GetMapping("/list")
    public List<Keypopulation> getAll() {
        return keypopulationService.getAll();
    }

    @PostMapping("/add")
    public int add(@RequestBody Keypopulation keypopulation) {
        return keypopulationService.add(keypopulation);
    }

    @DeleteMapping("/delete/{id}")
    public int delete(@PathVariable Integer id) {
        return keypopulationService.delete(id);
    }

    @PutMapping("/update")
    public int update(@RequestBody Keypopulation keypopulation) {
        return keypopulationService.update(keypopulation);
    }
}
